import { defineStore } from "pinia";
import { ref, reactive } from "vue";

import { reqHospitalDetail, reqHospitalDeparment } from '@/api/path'

export const useHospitalDetailStore = defineStore({
  id: "hospitalDetail",
  state: () => {
    return {
      hospitalInfo: {} as any,
      deparmentArr: [] as any[]
    }
  },
  actions: {
    async changeHospitalInfo(hoscode: string) {
      let res: any = await reqHospitalDetail(hoscode)
      if (res.code === 200) {
        this.hospitalInfo = res.data
      }
    },
    async getDeparment(hoscode: string) {
      let res: any = await reqHospitalDeparment(hoscode)
      if (res.code === 200) {
        this.deparmentArr = res.data
        console.log(this.deparmentArr);
        
      }
    }
  },
  getters: {}
})

// export const useHospitalDetailStore = defineStore('hospitalDetail', () => {
//   let hospitalInfo: any = ref({})

//   const changeHospitalInfo = async (hoscode: string) => {
//     let res: any = await reqHospitalDetail(hoscode)
//     if (res.code === 200) {
//       hospitalInfo.value = res.data
//     }
//   }
//   return { hospitalInfo, changeHospitalInfo }
// })